﻿@model Sealight.Core.DataAdapter.product_category
@{
    string name = string.Empty, image = string.Empty, description = string.Empty, template = string.Empty, parentId = string.Empty, categoryId = string.Empty;
    string priceRange = string.Empty, pictureId = string.Empty, imageUrl = "/ImageHandler.axd?imageSource=~/Content/images/no-photo-click.png&width=100&height=111"; ;
    int displayOrder = 0;
    bool publish = false;
    if (Model != null)
    {
        name = Model.name; 
        description = Model.description;
        categoryId = Model.id.ToString();
        if (Model.parent_id.HasValue)
        {
            parentId = Model.parent_id.Value.ToString();
        }
        displayOrder = Model.display_order;
        publish = Model.published;
        priceRange = Model.price_ranges;
        
        if(Model.picture != null)
        {
            image = Model.picture.picture_url;
            pictureId = Model.picture.id.ToString();
            imageUrl = string.Format("/ImageHandler.axd?imageSource=~/Content/images/pictures/{0}&width=100&height=111", Model.picture.picture_url);
        }
       
    }
   
}
<table class="adminContent">
    <tbody>
        <tr>
            <td class="adminTitle">
                <span id="" title="The category's name.">Tên loại:</span>
            </td>
            <td class="adminData">
                <input name="name_field" type="text" id="name_field" class="adminInput" value="@name"/>
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                <span id="" title="The category image.">Chọn hình:</span>
            </td>
            <td class="adminData">
                <img src="@imageUrl" id="picture_field_image" title="Picture" alt="Picture"/>
                <br />
                <br>
                <input type="file" name="file_field" id="file_field" title="Choose a new category image to upload."
                    class="adminInput"/>
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                <span id="" title="A description of the category.">Mô tả:</span>
            </td>
            <td class="adminData">
                <textarea id="description_field" name="description_field" style="width: 340px" rows="20"
                    class="Internal">@description</textarea>
            </td>
        </tr>
        <tr style="display:none;">
            <td class="adminTitle">
                <span id="" title="Choose a category template. This template defines how products within this category will be displayed. You can manage the templates from Content Management : Templates : Category Templates.">
                    Template:</span>
            </td>
            <td class="adminData">
                <select name="template_field" id="template_field" class="adminInput">
                
                </select>
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                <span id="" title="Select a parent category for this category. Leave as [ --- ] to make this the root level category">
                    Parent category:</span>
            </td>
            <td class="adminData">
               <!--Load category-->
               @Html.Partial("_ListCategory", categoryId)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                <span id="" title="Define the price ranges for the store price range filter. Separate ranges with a semicolon e.g. '0-199;200-300;301-;' (301- means 301 and over)">
                    Khung giá:</span>
            </td>
            <td class="adminData">
                <input name="price_range_field" type="text" id="price_range_field" class="adminInput" value="@priceRange">
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                <span id="" title="Check to publish this category (visible in store). Uncheck to unpublish (category not available in store)">
                    Published:</span>
            </td>
            <td class="adminData">
                @if (publish)
                {   
                    <input id="publish_field" type="checkbox" name="publish_field" checked="checked"/>
                }
                else
                {
                    <input id="publish_field" type="checkbox" name="publish_field"/>
                }
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                <span id="" title="Set the category's display order. 1 represents the top of the list.">
                    Thứ tự hiển thị:</span>
            </td>
            <td class="adminData">
                <input name="order_field" type="text" value="1" id="order_field" class="adminInput" value="@displayOrder">
            </td>
        </tr>
    </tbody>
</table>
<input type="hidden" id="category_id" value="@categoryId"/>
<input type="hidden" id="image_id" value="@pictureId"/>
<input type="hidden" id="image_url" value="@image"/>